package com.zero365.schedule;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.InterruptableJob;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;
import org.quartz.PersistJobDataAfterExecution;
import org.quartz.UnableToInterruptJobException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.zero365.autobak.ZipUtil;

@PersistJobDataAfterExecution
@DisallowConcurrentExecution
public class SimpleJob implements Job {

	private static Logger log = LoggerFactory.getLogger(SimpleJob.class);
	private JobKey jobkey=null;

	public void execute(JobExecutionContext context) throws JobExecutionException {
		jobkey = context.getJobDetail().getKey();
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日_HH时mm分ss秒");
		try {
			System.out.println("开始备份...");
			ZipUtil zipu=new ZipUtil();
			zipu.zip("D:/test", "d:\\Bak\\"+sdf.format(new Date())+".zip");
			//ZipCipherUtil zu=new ZipCipherUtil();
			//zu.encryptZip("D:/test", "d:\\Bak\\"+sdf.format(new Date())+".zip", "12345");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		log.info("SimpleJob says: " + jobkey + " executing at " + new Date());
		System.out.println("SimpleJob says: " + jobkey + " executing at " + new Date());
	}
   
}
